package com.wc.AlgoOJ_train.train1.c1.A109;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/12/26 10:29
 * 亲和数
 * http://43.138.190.70:8888/p/A109
 * @description
 */
public class Main {
    static int maxN = 6 * (int) 1e5;
    static int[] arr = new int[maxN + 7];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        arr[0] = arr[1] = -1;
        for (int i = 2; i <= maxN; i++) {
            arr[i] = gc(i);
        }
        while (n-- > 0) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == arr[b] || b == arr[a]) {
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }
        }
    }

    public static int gc(int num) {
        int mid = (int) Math.sqrt(num);
        int sum = 1;
        for (int i = 2; i <= mid; i++) {
            if (num % i == 0) {
                sum += i;
                sum += num / i;
            }
        }
        return sum;
    }
}
